package my.edu.model.bills.purchase.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import jakarta.validation.constraints.Min;
import jakarta.validation.groups.Default;
import lombok.Data;
import my.edu.common.myInterface.AccountCount;
import my.edu.common.myInterface.CanAudit;
import my.edu.common.validate.groups.Insert;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Date;

@Data
@TableName("purchase_return_order")
public class PurchaseReturnOrder implements CanAudit, AccountCount {
    @TableId(type = IdType.AUTO)
    private Long id;
    private String orderNo;
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private LocalDate orderDate;
    private BigDecimal discountRate;//优惠率
    private BigDecimal discountAmount;//退款优惠
    private Integer quantity;//退款数量
    private BigDecimal refundAmount;//退款金额
    private BigDecimal amountAfterDiscount;//优惠后金额
    private BigDecimal refundedAmount;//已退款金额
    //private BigDecimal refundedAmountWithPayableBalance;//供应商应付抵扣金额
    private String refundStatus;//退款状态
    //private String orderStatus;//
    private Integer isAudited;//是否审核
    private String remark;//
    private String deliveryMethod;//交货方式
    private Integer sourcePurchaseQuantity;//源购货数量
    private Long settlementAccountId;//结算账户ID
    private String settlementAccountName;//
    private Long logisticsId;//物流ID
    private String logisticsNo;//
    private Long supplierId;//供应商ID
    private String supplierName;//
    private Long salesmanId;//业务员ID
    private String salesmanName;//
    private Long purchaseOrderId;//购货单ID
    private String purchaseOrderNo;//
    private Long auditorId;//审核人ID
    private String auditorName;//
    @TableField(fill = FieldFill.INSERT)
    private Long createdBy;
    @TableField(fill = FieldFill.INSERT)
    private String createdName;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @TableField(fill = FieldFill.INSERT)
    private LocalDateTime createTime;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @TableField(fill = FieldFill.UPDATE)
    private LocalDateTime updateTime;
    @TableField(fill = FieldFill.UPDATE)
    private Long updatedBy;
    @TableField(fill = FieldFill.UPDATE)
    private String updateName;
    @Version
    private Integer version;

    @Override
    public BigDecimal getCirculatingMoney() {
        return refundedAmount;
    }
}